﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace ServerAdapter
{
    [CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
    public class SLClientListener : WcfGeebaService.IServiceCallback
    {
        // Event setting
        public delegate void OnUpdate(WcfGeebaService.GThread message, DateTime timestamp, bool isNotification);
        public delegate void OnEditMessage(string subforumTopic, WcfGeebaService.GThread message, DateTime timestamp);
        public event OnUpdate OnUpdateFromServer;
        public event OnEditMessage OnEditMessageFromServer;


        /// <summary>
        /// This method is called by Server
        /// </summary>
        /// <param name="message"></param>
        /// <param name="timestamp"></param>
        public void onUpdate(WcfGeebaService.GThread message, DateTime timestamp, bool IsNotification)
        {
            // Invoking OnUpdateFromController event - ClientNetworkAdaptor will be notified
            OnUpdateFromServer(message,timestamp, IsNotification);
        }

        /// <summary>
        /// This method is called by Server when editing post/thread
        /// </summary>
        /// <param name="message"></param>
        /// <param name="timestamp"></param>
        public void onEditMessage(string subforumTopic, WcfGeebaService.GThread message, DateTime timestamp)
        {
            // Invoking OnUpdateFromController event - ClientNetworkAdaptor will be notified
            OnEditMessageFromServer(subforumTopic, message, timestamp);
        }
    }
}
